<?php 
require_once 'sesi_login.php';
require_once 'konfigurasi.php';

fungsi('pengguna');

define('PAGE', 'Admin Jadwal Praktikum');
define('PAGE_ICO', 'icon-stats');
define('PAGE_URL', 'admin_jadwal_praktikum.php');

panggil_header();
koneksi_buka();

if(isset($_GET['soal_id'])){
	$soal_id = $_GET['soal_id'];
}


$text_q_hasil = "select a.nilai as 'nilai',b.hasil as 'hasil', f.nama as 'kelas', d.nis as 'nis', d.nama as 'nama', b.tot_benar as 'benar', c.tot_salah as 'salah', e.jumlah as 'jumlah' 
						from hasil_soal a 
								left join (
									select count(benar) as tot_benar, a.id as hasil 
										from hasil_soal a left join d_hasil_soal b on a.id = b.hasil 
											where b.benar=1  group by a.id) 
								b on a.id = b.hasil 
								
								left join (
									select count(benar) as tot_salah, a.id as hasil 
										from hasil_soal a left join d_hasil_soal b on a.id = b.hasil 
											where b.benar=0  group by a.id) 
								c on a.id = c.hasil
								
								left join siswa d on a.siswa = d.id 
								
								left join soal e on a.soal_id = e.id
								
								left join kelas f on d.kelas = f.id
								
						where a.soal_id ='$soal_id' ";
//echo $text_q_jadwal;
$q_hasil = mysql_query($text_q_hasil);

if($dt_hasil = mysql_fetch_array($q_hasil)){
	$nis = $dt_hasil['nis'];
	$nama = $dt_hasil['nama'];
	$benar = $dt_hasil['benar'];
	$salah = $dt_hasil['salah'];
	$kelas = $dt_hasil['kelas'];
	$hasil = $dt_hasil['hasil'];
	$jumlah = $dt_hasil['jumlah'];
	$nilai = $dt_hasil['nilai'];
}

?>

<div class="content">
                
	<div class="page-header">
		<div class="icon">
			<span class="ico-arrow-right"></span>
		</div> 
		<h1> Jadwal Praktikum<small>SDN I</small></h1>
	</div>
	
	<div class="row-fluid">
		<div class="span12">                

			<div class="block">
				<div class="head">                                
					<h2>Hasil Latihan</h2>
					<ul class="buttons">             
						<li><a href="#" onClick="source('form_pa'); return false;"><div class="icon"><span class="ico-info"></span></div></a></li>
					</ul>                                                                  
				</div> 
				<div class="row-fluid">                            
					<div class="span2">NIS</div>
					<div class="span10"><?php echo $nis?></div>
				</div> 
				<div class="row-fluid">                            
						<div class="span2">Nama</div>
						<div class="span10"><?php echo $nama?></div>
				</div>                 
				<div class="row-fluid">                            
					<div class="span2">Kelas</div>
					<div class="span10"><?php echo $kelas?></div>
				</div>    
				<div class="row-fluid">                            
					<div class="span2">Jawaban Benar</div>
					<div class="span10"><?php echo $benar?></div>
				</div>    
				<div class="row-fluid">                            
					<div class="span2">Jawaban Salah</div>
					<div class="span10"><?php echo $salah?></div>
				</div>    
				<div class="row-fluid">                            
					<div class="span2">Jumlah Soal</div>
					<div class="span10"><?php echo $jumlah?></div>
				</div>  
				
				<div class="row-fluid">                            
					<div class="span2"><h3><strong>Nilai</strong></h3></div>
					<div class="span10"><h3><strong><?php echo $nilai?></strong></h3></div>
				</div>  
			</div>
		</div>  
	</div>
	
	<div class="row-fluid">
		<div class="span12">
			<div class="block">
				<div class="head purple">
					<div class="icon"><span class="ico-book-3"></span></div>
					<h2>Daftar Jawaban</h2>				                                                         
				</div>    
				           
				<div class="data-fluid">
					<table cellpadding="0" cellspacing="0" width="100%" class="table fpTable lcnp">
						<thead>
							<tr>
								<th width="5%">
									No
								</th>
								<th width="40%">
									Pertanyaan
								</th>
								<th width="25%">
									Jawaban
								</th>
								<th width="25%">
									Jawaban Seharusnya
								</th>
								<th width="5%">
									Hasil
								</th>
							</tr>
						</thead>
						<tbody>
							<?php
								$text_q_d_hasil = "select b.no as no, b.pertanyaan as pertanyaan, c.nama as jawaban_hasil, d.nama as jawaban, if(a.benar, 'benar', 'salah') as benar 
														from d_hasil_soal a 
															left join d_soal b on a.no_d_soal = b.no 
															left join pilihan c on a.jawaban_hasil = c.no and b.id = c.d_soal 
															left join pilihan d on b.jawaban_pilihan_no = d.no and b.id = d.d_soal 
														where a.hasil = '$hasil' group by a.id";
								$q_d_hasil = mysql_query($text_q_d_hasil);
								
								while($dt_d_hasil = mysql_fetch_array($q_d_hasil)){
									
							?>
								<tr>
									<td>
										<?php echo $dt_d_hasil['no'];?>
									</td>
									<td>
										<?php echo $dt_d_hasil['pertanyaan'];?>
									</td>
									<td>
										<?php echo $dt_d_hasil['jawaban_hasil'];?>
									</td>
									<td>
										<?php echo $dt_d_hasil['jawaban'];?>
									</td>
									<td class="last-child-text">
										<span class="label <?php echo $dt_d_hasil['benar']=='benar'?'':'label-important';?>"> <?php echo $dt_d_hasil['benar'];?></span>
									</td>
								</tr>
							<?php
								}
							?>
						</tbody>
					</table>
				</div>  
				<br />
				<!--
				<div class="data-fluid">
					<div align="right">                  
						<button class="btn btn-primary" type="button">Cetak Semua</button>
					</div>   
				</div> 
				-->			 
			</div>
		</div>
	</div>
</div>

<div id="dialog-tambah-latihan" style="display:none;">
	<?php
		require_once 'modul/admin_latihan/tambah_latihan.php';
	?>
</div>

<div class="dialog" id="source" style="display: none;" title="Source"></div>

<?php
panggil_footer();
?>
